import 'dart:io';
import 'package:word_game/engine/npc.dart';
import 'package:yaml/yaml.dart';

import 'npc_factory.dart';

class NPCManager extends Object {
  static NPCManager instance = NPCManager();

  Map<String, NPC> _objectMap={};

  appendObjectsFromYAML(String fileName) {
    var content = File(fileName).readAsStringSync();
    var yaml = loadYaml(content);
    var items = yaml['npcs'] as List;
    for (var item in items) {
      NPC obj = NPCFactory.newNPCWithType(item['type'], item);
      
      _objectMap[obj.id] = obj;
    }
  }

  NPC objectWithID(String id) {
    return _objectMap[id];
  }

}